﻿Imports Publics

Public Class rptBaoCaoChotCaMau1
    Private _TuNgay As Date
    Public Property TuNgay() As Date
        Get
            Return _TuNgay
        End Get
        Set(ByVal value As Date)
            _TuNgay = value
        End Set
    End Property

    Private _DenNgay As Date
    Public Property DenNgay() As Date
        Get
            Return _DenNgay
        End Get
        Set(ByVal value As Date)
            _DenNgay = value
        End Set
    End Property


    Private _lstSourceAll As List(Of clsBaoCaoGiaoCa)
    Public Property lstSourceAll() As List(Of clsBaoCaoGiaoCa)
        Get
            Return _lstSourceAll
        End Get
        Set(ByVal value As List(Of clsBaoCaoGiaoCa))
            _lstSourceAll = value
        End Set
    End Property


    Private _IDNhanVien As String
    Public Property IDNhanVien() As String
        Get
            Return _IDNhanVien
        End Get
        Set(ByVal value As String)
            _IDNhanVien = value
        End Set
    End Property

    Private Sub rptBaoCaoChotCaMau1_BeforePrint(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintEventArgs) Handles MyBase.BeforePrint
        lbNhanVienThuNgan.Text = String.Format("TN: {0}", (From ds In dbTV.DM_NhanViens Where ds.InUsed AndAlso ds.ID = IDNhanVien Select ds.HoTen).FirstOrDefault)
        lbThoiGian.Text = String.Format("Thời gian in: {0:dd/MM/yyyy hh:mm:tt}", dbTV.GetDateTimeServer)

        For Each item In (From ds In lstSourceAll Join ds1 In lstSourceAllSanPham On ds.IDSanPham Equals ds1.ID).ToList
            item.ds.TenNhomSanPham = item.ds1.TenNhomSanPham
        Next
        Dim lstSource = (From ds In lstSourceAll Group By ds.TenNhomSanPham Into g = Group Select New With { _
                         .TenNhomSanPham = TenNhomSanPham, .SoLuong = g.Sum(Function(c As clsBaoCaoGiaoCa) c.SoLuong), _
                         .TienThanhToan = g.Sum(Function(c As clsBaoCaoGiaoCa) c.TienThanhToan)}).ToList

        binSource.DataSource = lstSource
    End Sub
End Class

Public Class clsBaoCaoGiaoCa
    Inherits ST_Func_BaoCaoBanHangTheoThoiGianResult


    Private _TenNhomSanPham As String
    Public Property TenNhomSanPham() As String
        Get
            Return _TenNhomSanPham
        End Get
        Set(ByVal value As String)
            _TenNhomSanPham = value
        End Set
    End Property

    Private _IDNhomSanPham As String
    Public Property IDNhomSanPham() As String
        Get
            Return _IDNhomSanPham
        End Get
        Set(ByVal value As String)
            _IDNhomSanPham = value
        End Set
    End Property


End Class